<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
    <script type="text/html" id="tpl-user">
        <div>姓名：{{ name}}</div>
        <div>年龄：{{ age }}</div>
        <div>性别{{ gender}}</div>
        <div>住址{{ address}}</div>
    </script>
</head>

<body>
    <div id="info"></div>
    <script src="./my-template.js"></script>
    <script>
        var data = {
            name: "zs",
            age: 28,
            gender: "男",
            address: "安徽合肥"
        };
        var ret = myTemplate("tpl-user", data);
        console.log(ret);
        var div = document.getElementById("info");
        div.innerHTML = ret;
    </script>
</body>

</html>